﻿package net.wangit.dev.incrementor;

import net.wangit.jdbc.DB;
import net.wangit.jdbc.table.TableCache;
import net.wangit.util.Checker;

public class IncrementorReferenceUtil {

	public static final String SQL_REFERENCE = "update COLUMN set g=? where g=?";

	public IncrementorReferenceUtil() {
	}

	public static void update(DB db, String domain, String oldGeneratorId,
			String newGeneratorId) throws Exception {
		if (!Checker.isEmpty(oldGeneratorId)
				&& !oldGeneratorId.equals(newGeneratorId)) {
			db.execute(IncrementorReferenceUtil.SQL_REFERENCE, new String[] {
					newGeneratorId, oldGeneratorId }, new int[] { 2, 2 });
			TableCache.clearAll(domain);
		}
	}
}
